﻿using System.Security.Cryptography.X509Certificates;
using Ipmce.RemoteVoting.Common.Entities;
using Ipmce.RemoteVoting.Common.Tools.UnitTests.Properties;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ipmce.RemoteVoting.Common.Tools.UnitTests
{
	[TestClass]
	public class VoteEncryptionTests
	{
		[TestMethod]
		public void TestEncryption()
		{
			var encryptor = new VoteEncryptor(new X509Certificate2(Resources._public));
			var candidate = new Candidate
			                	{
			                		Fio = "Doesn't metter",
									Id = 10
			                	};
			var encrypted = encryptor.Encrypt(candidate);
			Assert.IsNotNull(encrypted);
			var decrytor = new VoteEncryptor(new X509Certificate2(Resources._private, "123"));
			var decrypted = decrytor.Decrypt(encrypted);
			Assert.IsNotNull(decrypted);
			Assert.AreEqual(candidate.Id, decrypted.Id);
		}
	}
}
